import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  isLoading: false,
  currentGoodId: 0,
  basicInfo: []
}

const mutations = {
  setLoadingStatus (state, isLoading) {
    state.isLoading = isLoading
  },
  setBasicInfo (state, basicInfo) {
    state.basicInfo = basicInfo
  },
  setCurrentGoodId (state, currentGoodId) {
    state.currentGoodId = currentGoodId
  }
}

const actions = {
  async loadingStatus ({ commit }, isLoading) {
    commit('setLoadingStatus', isLoading)
  },
  async basicStatus ({ commit }, basicInfo) {
    commit('setBasicInfo', basicInfo)
  },
  async currentGoodIdStatus ({ commit }, currentGoodId) {
    commit('setCurrentGoodId', currentGoodId)
  }
}

export default new Vuex.Store({
  state,
  actions,
  mutations
})
